<template>
	<view class="navBox">
		<scroll-view 
		enhanced="true"
		bounces="false"
		scroll-x="true" >
			<view class="tab">
				<view class="tab-nav">
					<view v-for="(item,index) in list" :key="index" 
					:id="'glsntb-' + index"
					@click="setTab(index,item)">
						<view :class="['nav-item',index===showtab?'active':'']" 
						:style="{color:index===showtab?activeColor:'',width:width}"
						>
							{{item.name}}
							<view class="underLine" v-if="index===showtab">
									<view class="underline-item" :style="{background:activeBorder}">
										
									</view>	
							</view>
						</view>
						
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>
<script>
export default {
	props:{
		list:{
			type:Array
		},
		actindex:{
			type:Number
		},
		// 激活的颜色
		activeColor:{
			type:String,
			default:'#333'
		},
		// 下划线激活颜色
		activeBorder:{
			type:String,
			default:'#333'
		},
		// 长度
		width:{
			type:String,
			default:'120rpx'
		}
	},
	data() {
		return {
			// 顶部选项卡索引
			showtab: 0, 
			curscrollitem: 'glsntb-0',
			productList: []
		};
	},

	methods: {
		setTab(idx,val) {
			this.showtab = idx;
			this.curscrollitem = 'glsntb-' + idx; 
			this.$emit('clickitem', {idx, val});
		}
	},
	watch: {
		actindex() {
			this.showtab = this.actindex;
		}
	},
	created() {
		this.showtab = this.actindex;
	},
	computed: {
	
	},
};
</script>
<style lange="scss" scoped>
	::-webkit-scrollbar {
	width: 0;
	height: 0;
	color: transparent;
	display: none;
	}
	.navBox{
		width: 100%;
		white-space:nowrap;
	}
.tab {
	display: flex;
	flex-direction: column;
	width: 100%;
	overflow: auto;
}
.active{
	
	font-size: 28rpx!important;
	
}
.underLine{
display: flex;
justify-content: center;
		width: 100%;
		position: absolute;
		bottom: 5rpx;
	
}
.underline-item{
	width: 50%;
    height: 5rpx;
	border-radius: 4rpx; 
}
/* .glance-slidenav-tabbar-itme-underline {
		border-radius: 10upx;
		-webkit-border-radius: 10upx;
		-moz-border-radius: 10upx;
		background-color:$theme-color-r;
		transition:.5s all;
		} */
.tab-nav {
	height: 80rpx;
	background: #fff;
	font-size: 24rpx;
	font-family: PingFangSC, PingFangSC-Regular;
	display: flex;
	line-height: 79rpx;
	position: relative;
	overflow: auto;
}
.nav-item {
	width: 120rpx;
	/* max-width: 20%; */
	text-align: center;
	font-size: 24rpx;
	color: #999;
	height: 80rpx;
	position: relative;
}
.tab-line {
	position: absolute;
	left: 0;
	bottom: 1rpx;
	height: 4rpx;
	background: #333;
	transition: all 0.3s;
}
.tab-content {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
}
</style>
